package com.hbnu.tagyalu;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class InputStreamReaderDemo {
    public static void main(String[] args) {
        String path="D:"+ File.separator+"program"+File.separator+"tttt.txt";
        File file=new File(path);
        InputStreamReader inputStreamReader=null;
        try {
            inputStreamReader=new InputStreamReader(new FileInputStream(file));
            char[] buff=new char[1024];
            int len=0;
            int temp;
            while ((temp=inputStreamReader.read())!=-1){
                buff[len++]=(char) temp;
            }
            System.out.println(new String(buff,0,len));
        }
        catch (Exception e){
            e.printStackTrace();
        }
        finally {
            try {
                if (inputStreamReader!=null){
                    inputStreamReader.close();
                }
            }
            catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
